Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Allow route setting to be "" #1352

Merged
merged 1 commit into from
Jun 27, 2022
Merged

bugfix: Allow route setting to be "" #1352

merged 1 commit into from
Jun 27, 2022

Conversation

JacobMGEvans
Copy link
Contributor

Previously Wrangler1 had allowed for route = "".
Wrangler now will allow for empty route = "" to represent not setting a route, while providing a warning.

resolves #1329

@JacobMGEvans JacobMGEvans added the bug Something that isn't working label Jun 24, 2022
@changeset-bot
Copy link

changeset-bot bot commented Jun 24, 2022

🦋 Changeset detected

Latest commit: 5be0c1e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jun 24, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2572148204/npm-package-wrangler-1352

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1352/npm-package-wrangler-1352

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2572148204/npm-package-wrangler-1352 dev path/to/script.js

const triggers = props.triggers || config.triggers?.crons;

if (config.route === "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if one of config.routes is also ""?

Copy link
Contributor Author

@JacobMGEvans JacobMGEvans Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are allowing for empty strings for an explicit representation of "routes not being set" and routes is used for many routes is there a case where routes = [ "", "some-route/* ] or just routes = [ "" ] because I had originally coded this with those two scenarios in mind but it didn't fully make sense... like why would someone use routes for one route anyway (I actually couldn't think of a use-case for myself)?

const triggers = props.triggers || config.triggers?.crons;

if (config.route === "") {
logger.warn("Route/s is being set as an empty string");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should the user do if they see this message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wasn't discussed. I think it should include the "" will not be published and is being ignored, or something to that effect.

@threepointone
Copy link
Contributor

  • "" isn't a valid route, so enabling it to be so in isValidRoute() is probably wrong
  • The test shows that "" is sent to the api as a valid route when published, that seems wrong. When actually running this, what's the result? Does the api accept it? Or is it an error?
  • What's the behaviour with wrangler 1?
  • In wrangler 2, we default workers_dev as true when there isn't a route. If "" is now a valid route, what's the behaviour? Is it correct?
  • Because "" is now showing as a valid route. it'll now be accepted if provided as a value inside routes = [...]. Is this correct?
  • The log "Route/s is being set as an empty string" (grammar aside), isn't helpful. What should be the message here? What suggestion can we give the user? (Or should we do so at all?) If we ask them to change the value, should be change the templates themselves? What's the wrangler 1 behaviour if we remove the route = "" line from templates?
  • I think the fix here should be for route = "" to be normalised as route: undefined during the config validation phase. Do you agree? What are the implications?

Let's answer each of these questions, make sure we have tests for combinations, and then land it.

@petebacondarwin
Copy link
Contributor

I think the fix here should be for route = "" to be normalised as route: undefined during the config validation phase. Do you agree? What are the implications?

💯

@JacobMGEvans JacobMGEvans force-pushed the empty-string-route branch 2 times, most recently from 11f774a to 2749b2d Compare June 27, 2022 20:01
Previously Wrangler1 behavior had allowed for . To keep parity it will be possible to set  in the config file and represent not setting a route, while providing a warning.

resolves #1329
mockUpdateWorkerRequest({ enabled: false });
mockUploadWorkerRequest({ expectedType: "esm" });
mockSubDomainRequest();
mockPublishRoutesRequest({ routes: [] });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this will only fail if we actually make a request to publish routes with a non-empty array of routes. If the API request is never made, this would pass whatever you put for routes here.

@JacobMGEvans JacobMGEvans merged commit 4e03036 into main Jun 27, 2022
@JacobMGEvans JacobMGEvans deleted the empty-string-route branch June 27, 2022 21:41
@github-actions github-actions bot mentioned this pull request Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: allow route setting to be empty string
3 participants